#ifndef DHWL_SOCKET_IOBYTESTRING_H
#define DHWL_SOCKET_IOBYTESTRING_H


#include "ByteString.h"
#include "Sock.h"

namespace ZY {

    class IOByteString : public ByteString
    {
        public:
            IOByteString() : sock(0) {};
            IOByteString( Sock *sock ) : sock( sock ) {};
            IOByteString( Sock & sock ) : sock( & sock ) {};
            virtual ~IOByteString();

            void setSock( Sock & sock ) { this->sock = & sock ;};
            void setSock( Sock *sock ) { this->sock = sock; };

            IOByteString *setUnsignedInt64( uint64_t n ) {ByteString::setUnsignedInt64(n);return this;};
            IOByteString *setInt64( int64_t n ) {ByteString::setInt64(n);return this;};

            IOByteString *setUnsignedInt32( uint32_t n ) {ByteString::setUnsignedInt32(n);return this;};
            IOByteString *setInt32( int32_t n ) {ByteString::setInt32(n);return this;};

            IOByteString *setUnsignedInt16( uint16_t n ) {ByteString::setUnsignedInt16(n);return this;};
            IOByteString *setInt16( int16_t n ) {ByteString::setInt16(n);return this;};

            IOByteString *setUnsignedInt8( uint8_t n ) {ByteString::setUnsignedInt8(n);return this;};
            IOByteString *setInt8( int8_t n ) {ByteString::setInt8(n);return this;};

            IOByteString *setCharArray( const char *c , size_t size ) {ByteString::setCharArray( c , size);return this;};
            IOByteString *setString( const string & str ) {ByteString::setString( str );return this;};

            IOByteString *setVarCharArray( const char *c , size_t size ) {ByteString::setVarCharArray(c,size);return this;};
            IOByteString *setVarString( const string & str ) {ByteString::setVarString(str);return this;};

            IOByteString *setByteString( ByteString & bs ){ ByteString::setByteString(bs);return this;};

            virtual void send();
            virtual void nativeSend();
        protected:
            Sock *sock;
        private:


    };

    class ThreadIOByteString : public IOByteString
    {
        public:
            void send();
            void nativeSend();
            static void mainSend( ByteString &bs );
            static void mainNativeSend( ByteString &bs );

    };
}
#endif // IOBYTESTRING_H
